import { _decorator, Component, Node, Tween, tween, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('bgload')
export class bgload extends Component {

    //背景
    @property(Node)
    private Bg: Node = null;

    protected start(): void {
        for (let star of this.Bg.children) {
            this.PlayAni1(star);
        }

    }

    /**
     * 
     * @param dt 
     */
    public PlayAni1(star: Node) {
        star.setPosition(new Vec3(-300 + Math.random() * 600, Math.random() * 500, 0));
        let sale_num: number = 0.1 + Math.random() * 0.1;
        let time_num: number = 0.2 + Math.random() * 1;
        let time_num1: number = 0.3 + Math.random() * 0.5;
        tween(star).set({ scale: new Vec3(0, 0, 0) }).
            delay(time_num1).
            to(time_num, { scale: new Vec3(sale_num, sale_num, sale_num) })
            .to(time_num, { scale: new Vec3(0, 0, 0) }).call(() => {
                this.PlayAni1(star);
            })
            .start();
    }

}


